package jdbc;

import com.sun.org.apache.bcel.internal.generic.ACONST_NULL;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Demo8 {
    public static void main(String[] args) throws SQLException {
        try {
            Connection con=DBUtil.getConnection();
            String sql="SELECT username,password "+
                       "FROM user "+
                       "WHERE username=? AND password=? ";
            PreparedStatement ps= con.prepareStatement(sql);
            ps.setString(1,"陈平安");
            ps.setString(2,"456789");
            ResultSet re=ps.executeQuery();
            if(re.next()){
                System.out.println("登陆成功");
            }else{
                System.out.println("登录失败");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
